
public class PointDriver {

	public static void main(String[] args) {

		Point[] points_array = new Point[5];
		points_array[0] = new Point(3, 5);
		points_array[1] = new Point(3, 8);
		points_array[2] = new Point(4, -1);
		points_array[3] = new Point(2, -3);
		points_array[4] = new Point(1, 7);

		Point origin = new Point(0, 0);

		int closest_index = 0;

		for (int k = 1; k < points_array.length; k++) {
			if (points_array[k].distanceFrom(origin) < points_array[k - 1].distanceFrom(origin))
				closest_index = k;
		}

		System.out.printf("The nearest point from origin is: %s %nThe distance is: %.2f",
				points_array[closest_index].toString(), points_array[closest_index].distanceFrom(origin));

	}

}
